package unteractivities.p3_fitnessapp;

import java.text.DecimalFormat;

import nutrients.p3_fitnessapp.Nutrientscalc;
import nutrients.p3_fitnessapp.ResultNutrients;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.widget.TextView;
import controler.p3_fitnessapp.R;

public class UActNutrients3 extends Activity {

	private int _weight;
	private int _heigth;
	private String _bodytype;
	private String _phase;

	private int _work;
	private int _sport;

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.uact_nutrients_calc_3);

		// Log.d(null,"gewicht: " + intent.);

	}

	@Override
	protected void onResume() {
		
		DecimalFormat format = new DecimalFormat("#0.00");

		Nutrientscalc calc = new Nutrientscalc();

		super.onResume();

		TextView tv_bmi = (TextView) findViewById(R.id.tv_bmi);
		TextView tv_grundCal = (TextView) findViewById(R.id.tv_grundCal);
		TextView tv_protG = (TextView) findViewById(R.id.tv_prot_G);
		TextView tv_carbG = (TextView) findViewById(R.id.tv_carbo_G);
		TextView tv_fatG = (TextView) findViewById(R.id.tv_fat_G);

		Intent intent = getIntent();

		_weight = intent.getIntExtra("weight", 0);
		_heigth = intent.getIntExtra("heigth", 0);
		_bodytype = intent.getStringExtra("bodytype");
		_phase = intent.getStringExtra("phase");

		_work = intent.getIntExtra("work", 0);
		_sport = intent.getIntExtra("sport", 0);

		Log.d(null, "w " + _weight + ", h " + _heigth + " , b " + _bodytype
				+ " , p " + _phase + " , work " + _work + " , sport " + _sport);

		tv_bmi.setText("" + calc.calculateBMI(_heigth, _weight));
		tv_grundCal.setText("" + calc.calculateSMRFull(_weight, _work, _sport));

		// FIXME Return fehlt, Methoden auslagern !!!

		ResultNutrients result = calc.calculateDetailed(_phase, _bodytype);

		tv_protG.setText(" " + format.format(result.getProtein()) + " g");
		tv_carbG.setText(" " + format.format(result.getCarbon()) + " g");
		tv_fatG.setText(" " + format.format(result.getFat()) + " g");
		
		Log.d(null, "FU !!!");

		// tv_carbG.setText("" + calc.calculateBMI(_heigth, _weight));
		// tv_fatG.setText("" + calc.calculateBMI(_heigth, _weight));

	}

	/*
	 * ==========================================================================
	 * Globale Variablen
	 * ========================================================
	 */

	/*
	 * ==========================================================================
	 * Android Methoden ========================================================
	 */

	/*
	 * ==========================================================================
	 * Benutzer Interaktion (Buttons ... )
	 * ========================================================
	 */

	/*
	 * ==========================================================================
	 * Eigene Methoden ========================================================
	 */

	/*
	 * ==========================================================================
	 * Debug Methoden ========================================================
	 */

	/*
	 * ==========================================================================
	 * Getter und Setter
	 * ========================================================
	 */
}
